// 类组件的计数器
import React from 'react'

class Count extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            name: '计数器',
            age: 18,
            count: 0
        } // 这里定义你的自定义状态
    }

    // 对象解构
    add() {
        this.setState({ ...this.state, count: this.state.count + 1 })
    }
    render() {
        return <div>
            <p>{this.state.count}</p>
            <button onClick={() => this.add()}>点我+1</button>
        </div>
    }
}

export default Count